<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>综合成绩查询</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="static/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="static/layuiadmin/style/admin.css" media="all">
</head>
<body>
<!--templates/table/zhcjcx-->
<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header card-title">综合成绩查询</div>
        <div class="layui-card-body">
          <form class="layui-form" lay-filter="component-form-group" id="search_submits" onsubmit="return false">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="layadmin-useradmin-formlist">
              <div class="layui-inline">
                <a class="layui-btn btn-add btn-default" id="export">导出数据</a>
              </div>
            </div>
          </form>
          <table class="layui-hide" id="test-table-cellEdit" lay-filter="test-table-cellEdit"></table>
          <script type="text/html" id="test-table-operate-barDemo">
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="bingo">确认成绩</a>
          </script>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="static/layui/layui.js"></script>
<script th:inline="none">
  layui.config({
    base: 'static/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'table','form'], function(){
    var $ = layui.$;
    var table = layui.table;
    var form = layui.form;
    var exportData;
    var loading = layer.load();
    var ins1 = table.render({
      elem: '#test-table-cellEdit'
      ,method:'post'
      , url: '/selectzhcjcx'
      , cols: [[
        {field: 'username', title: '学生姓名', width: 120, sort: true}
        ,{field: 'zxfjd', title: '总学分绩点', width: 180, sort: true}
        ,{field: 'zhcj', title: '综合成绩', width: 180, sort: true}
        ,{field: 'yscj', title: '原始成绩', width: 180, sort: true}
        ,{field: 'ztname', title: '目前状态', width: 180, sort: true}
        ,{field: 'xq', title: '学期', width: 180, sort: true}
        , {width: 178, align: 'center', fixed: 'right', toolbar: '#test-table-operate-barDemo'}
      ]]
      , done: function (res, curr, count) {
        layer.close(loading);
        exportData = res.data;
      }
    })
      $("#export").click(function() {
        table.exportFile(ins1.config.id, exportData, 'xls');
      });
    //监听工具条
    table.on('tool(test-table-cellEdit)', function(obj){
      var data = obj.data;
      if(obj.event === 'bingo') {
        if (data.ztname == '已确认') {
          layer.msg('已确认的成绩无需再次确认', {icon: 2});
          return;
        }
        if (data.ztname == '有异议') {
          layer.msg('此成绩已经上报异议，请教师处理完再确认', {icon: 2});
          return;
        }
        layer.confirm('真的确认成绩么？（注意：确认的成绩将不可申诉异常）', function(index){
          $.ajax({
            url:"/qrcj",
            data:{id:data.id},
            type:"post",
            dataType:"json",
            success: function (result) {
              layer.msg('已确认',{icon:1});
            },
            error:function (e) {
              layer.msg('确认失败',{icon:2});
            }
          })
          layer.close(index);
        });
      }
    });
  });

</script>
</body>
</html>